{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-14T00:46:55.646879Z",
     "iopub.status.busy": "2023-11-14T00:46:55.646685Z",
     "iopub.status.idle": "2023-11-14T00:46:56.016001Z",
     "shell.execute_reply": "2023-11-14T00:46:56.015383Z",
     "shell.execute_reply.started": "2023-11-14T00:46:55.646854Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "stage = 'A'\n",
    "\n",
    "df_train = pd.read_csv('../../../contest/train/GSLD_NATURE_CUST.csv')\n",
    "df_test = pd.read_csv('../../../contest/A/GSLD_NATURE_CUST_A.csv')\n",
    "\n",
    "save_path = '../data'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-14T00:46:56.017291Z",
     "iopub.status.busy": "2023-11-14T00:46:56.017099Z",
     "iopub.status.idle": "2023-11-14T00:46:56.022129Z",
     "shell.execute_reply": "2023-11-14T00:46:56.021510Z",
     "shell.execute_reply.started": "2023-11-14T00:46:56.017267Z"
    }
   },
   "outputs": [],
   "source": [
    "rank = {'A':0,'B':1,'C':2,'D':3,'E':4, 'F':5}\n",
    "sex = {'A':0,'B':1}\n",
    "def prepro(df):\n",
    "    del df['DATA_DAT']\n",
    "    del df['NTRL_SEAN_ACTV_IND'] # 没用\n",
    "    df['NTRL_CUST_SEX_CD'] = df['NTRL_CUST_SEX_CD'].map(sex)\n",
    "    df['NTRL_RANK_CD'] = df['NTRL_RANK_CD'].map(rank)\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-14T00:46:56.023387Z",
     "iopub.status.busy": "2023-11-14T00:46:56.023205Z",
     "iopub.status.idle": "2023-11-14T00:46:56.043089Z",
     "shell.execute_reply": "2023-11-14T00:46:56.042563Z",
     "shell.execute_reply.started": "2023-11-14T00:46:56.023364Z"
    }
   },
   "outputs": [],
   "source": [
    "df_train = prepro(df_train)\n",
    "df_test = prepro(df_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-14T00:46:56.044120Z",
     "iopub.status.busy": "2023-11-14T00:46:56.043910Z",
     "iopub.status.idle": "2023-11-14T00:46:56.206653Z",
     "shell.execute_reply": "2023-11-14T00:46:56.206139Z",
     "shell.execute_reply.started": "2023-11-14T00:46:56.044097Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "df_train.to_csv(save_path+'/GSLD_NATURE_CUST.csv', index=False)\n",
    "df_test.to_csv(save_path+'/GSLD_NATURE_CUST_A.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
